package cn.yangliu.nacos.comm.audit;

import java.io.Serializable;
import java.time.LocalDateTime;

import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import cn.yangliu.nacos.comm.constant.GlobalConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-01
 */
@MappedSuperclass
@Data
@EntityListeners(AuditingEntityListener.class)
public class AbstractEntity implements Serializable {

    /**
     * current class's static member
     * The constant serialVersionUID.
     */
    private static final long serialVersionUID = 3896958049250603272L;

    /**
     * current class instance's member.
     * The Id.
     */
    @Id
    @GeneratedValue
    private Long id;

    /**
     * current class instance's member.
     * The Create time.
     */
    @CreatedDate
    @JsonFormat(pattern = GlobalConstants.DATETIME)
    @DateTimeFormat(pattern = GlobalConstants.DATETIME)
    private LocalDateTime createTime;

    /**
     * current class instance's member.
     * The Update time.
     */
    @LastModifiedDate
    @JsonFormat(pattern = GlobalConstants.DATETIME)
    @DateTimeFormat(pattern = GlobalConstants.DATETIME)
    private LocalDateTime updateTime;

    /**
     * current class instance's member.
     * The Updater.
     */
    @LastModifiedBy
    private String updater;

    /**
     * current class instance's member.
     * The Creator.
     */
    @CreatedBy
    private String creator;

    /**
     * current class instance's member.
     * The Remark.
     */
    private String remark;

}
